#include "gold.h"

Gold::Gold()
{

    //资源加载
    m_gold.load(GOLD_PATH);
    //位置
    m_x=-1000;
    m_y=0;

    //状态
    m_Free=1;

    //速度
    m_Speed=UPGRADE_SPEED;

    //矩形框
    m_Rect.setWidth(m_gold. width());
    m_Rect.setHeight(m_gold.height());
    m_Rect.moveTo(m_x,m_y);
}

void Gold::updatePosition()
{
    //空闲状态不计算坐标
    if(m_Free)
    {
        return;
    }
    m_y+=m_Speed;
    m_Rect.moveTo(m_x,m_y);
    //如果超出屏幕  重置空闲状态
    if(m_y>=GAME_HEIGHT+m_gold.height())
    {
       m_Free=1;
    }
}
